// hyb_yl/mysubpages/pages/patientman/patientman.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    page: 0,
    pagesize: 10,

  },
  doctab: function (e) {

    const index = e.currentTarget.dataset.dex;
    this.setData({
      docindex: index,
      list: [],
      page: 0,
    })
    wx.showLoading({
      title: 'login..',
    })
    this.getList(index)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var parentid = options.parentid;
    
    that.setData({
      parentid: parentid,
    })
    that.getList();

  },
  getList: function () {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/regin.hospital_user',
      data: {
        parentid: that.data.parentid,
        page: that.data.page,
        pagesize: that.data.pagesize,
        openid:wx.getStorageSync('openid')
      },
      success: function (res) {
       
        var page = that.data.page + 1;
        that.setData({
          list: that.data.list.concat(res.data),
          page: page
        })
        wx.hideLoading()
      }
    })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getList()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  see(e) {
    var that = this
    var change = e.currentTarget.dataset.change
    var openid = e.currentTarget.dataset.openid
    var titlme = e.currentTarget.dataset.names
    if (change == '1') {
      wx.navigateTo({
        url: '/hyb_yl/zhuanjiasubpages/pages/danganList/danganList?openid=' + openid + '&doc=1' + '&type=1' + '&titlme=' + titlme,
      })
    } else {
      wx.showToast({
        title: '患者未授权',
        icon: 'none'
      })
    }
  },
  tongguo(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updateqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  },
  jujue(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updatejujueqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  },
  jiechu(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updatejiechuqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  }
})